
package org.sopt.dev.ImgKnight.agent.database;

import java.sql.SQLException;
import java.util.List;

import org.apache.log4j.Logger;

import com.ibatis.sqlmap.client.SqlMapClient;

public class HarvestDAO {

	private SqlMapClient sqlMap = SqlMap.getInstance();
	
	private Logger exceptionLogger = null;
	
	public HarvestDAO() {
		exceptionLogger = Logger.getLogger("agent.exception");
	}
	
	public boolean insertHarvest(HarvestVO t) {
		try {
			sqlMap.insert("insertHarvest", t);
			return true;
		} catch (SQLException e) {
			exceptionLogger.error("Unexpected exception: "+e.getMessage());
		}
		return false;
	}
	
	public boolean insertHarvest(List<HarvestVO> lt) {
		try {
			sqlMap.startBatch();
			for(HarvestVO t : lt) {
				sqlMap.insert("insertHarvest", t);
			}
			sqlMap.executeBatch();
			return true;
		} catch (SQLException e) {
			exceptionLogger.error("Unexpected exception: "+e.getMessage());
		} 
		return false;
	}
}
